﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;

namespace BaMusaSoft.RPS.ViewModel.HelperClasses
{
    public static class ExtenstionMethods
    {
        public static T DeepClone<T>(this T a)where T:class
        {
            if (a == null) throw new ArgumentNullException("a");
            using (var stream = new MemoryStream())
            {
                var formatter = new BinaryFormatter();
                formatter.Serialize(stream, a);
                stream.Position = 0;
                return (T) formatter.Deserialize(stream);
            }
        }
    }
}
